﻿using System.Collections.Generic;
using UnityEngine;

namespace Extend.Pool
{
    public class GameObjectPool : UnityObjPoolBase<GameObject>
    {
        /*
         Unity GameObject 池
             */

        protected GameObjectPool()
        {

        }

        public static GameObjectPool Create(GameObject original, Transform parent = null, int capacity = int.MaxValue)
        {
            GameObjectPool pool = new GameObjectPool();
            pool.Init(original, parent, capacity);
            return pool;
        }

        protected override GameObject GetGameobject(GameObject t)
        {
            return t;
        }

        protected override GameObject GetNewInstance()
        {
            var go = GameObject.Instantiate(_original);
            go.transform.SetParent(_parent, false);
            return go;
            //return GameObject.Instantiate(_original, _parent);
        }

        protected override Transform GetTransform(GameObject t)
        {
            return t.transform;
        }
    }
}
